﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;


namespace typewriter
{
    public partial class widge : Form
    {
        #region Form Dragging API Support
        //The SendMessage function sends a message to a window or windows.

        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]

        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

        //ReleaseCapture releases a mouse capture

        [DllImportAttribute("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]

        public static extern bool ReleaseCapture();

        #endregion

        public widge()
        {
            InitializeComponent();
        }
        public widge(int w, int h)
        {
            InitializeComponent();
            this.Width = w;
            this.Height = h;
        }

        public void setPos(Point p) {
            this.Location = p;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Pen bpen = new Pen(Brushes.Black, 2);
            GraphicsPath path = RoundedRectangle.Create(1, 1, this.Width-1, this.Height-1, 8);
            e.Graphics.FillPath(Brushes.White, path);
            e.Graphics.SetClip(path);

            Brush linearGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), Color.Black, Color.Gray,90);
            e.Graphics.FillRectangle(linearGradientBrush, new Rectangle(0, 0, this.Width, this.Height));

            linearGradientBrush.Dispose();





            /*
            GraphicsPath path = RoundedRectangle.Create(5, 5, 20, 20);
            e.Graphics.DrawPath(Pens.Black, path);
            
            path = RoundedRectangle.Create(8, 50, 50, 50, 5);
            e.Graphics.DrawPath(Pens.Black, path);

            e.Graphics.SetClip(path);
            using (Font f = new Font("Tahoma", 12, FontStyle.Bold))
                e.Graphics.DrawString("Draw Me!!", f, Brushes.Red, 0, 70);
             */
            //e.Graphics.DrawPath(bpen, path);
            e.Graphics.ResetClip();
            base.OnPaint(e);
        }




        private void widge_Load(object sender, EventArgs e)
        {

        }

        private void pbHandel_Click(object sender, EventArgs e)
        {

        }

        private void widge_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(this.Handle, 0xa1, 0x2, 0);
            }
        }

        public void widge_MD(object sender, MouseEventArgs e) {
            if (e.Button == MouseButtons.Left) {
                ReleaseCapture();
                SendMessage(this.Handle, 0xa1, 0x2, 0);
            }
        }

    }
}
